﻿<?php
/**
 * Created by PhpStorm. User: ADun, Date: 14/12/7 上午11:55
 * Description:
 */

header("Content-type: text/html; charset=utf-8");
require 'system.hermes.php';

if($argc<2) die('error: 请输入命令行参数');

echo 'Hermes引擎:'.$argv[1]."\n";
function toGB18030($file_name){
    if('WINNT' == PHP_OS)
        return mb_convert_encoding($file_name,'toGB18030');
    return $file_name;
}
function toUTF8($file_name){
    if('WINNT' == PHP_OS)
        return mb_convert_encoding($file_name,'utf-8','gb18030');
    return $file_name;
}
switch (trim($argv[1])){
    case 'TestCode':
        if ($argc < 4) {
            die("Usage: php $argv[0] <file_path> <class_name> [bootstrap] [author = dogstar]\n");
        }

        $file_path = toGB18030($argv[2]);
        $class_name = $argv[3];
        $strap = isset($argv[4]) ? $argv[4] : null;

        Hermes::打印测试代码($file_path,$class_name,$strap);

        break;
    case 'DO':
        if($argc<3){
            die('请输入表名,如果要生成所有表的DO,请输入:ALL');
        }

        $table=toUTF8($argv[2]);
       // $table = toUTF8( '用户');

        if(strtolower($table)=='all') $table=null;

        Hermes::数据库表生成DO($table);
        break;
    default:
        echo 'error:'.$argv[1];
        break;
}